﻿using UnityEngine;
using System.Collections;

public class MoveAnimation : MonoBehaviour {

    public Transform Destination;
    public float Duration = 3.0f;
    public bool IsPingPong = true;
    public bool AutoStart = true;

    private bool started = false;
    private bool paused = false;
    // Use this for initialization
    void Start() {
        if (AutoStart) {
            Play();
        }
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    public void Play() {
        iTween.MoveTo(gameObject, iTween.Hash(
            "position", Destination.position,
            "time", Duration,
            "easeType", "linear",
            "looptype", IsPingPong ? "pingPong" : "none"));
        started = true;
    }

    public void Pause() {
        if (started) {
            iTween.Pause(gameObject);
            paused = true;
        }
    }

    public void Resume() {
        if (paused) {
            iTween.Resume(gameObject);
        }
    }
}
